Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development
Repository Manager API
These are a few of the most useful methods in the Repository Manager API. The principal body of code for the Repository Manager is in the include file
ry/app/ryrepmngrp.i.cacheObjectOnClient
The function
cacheObjectOnClientchecks if the requested object exists in the client-side cache. If the requested object is not in the cache, it is retrieved from the Repository and placed in the cache. This function returns a logical value signifying the success of the operation.The
cacheObjectOnClient()function ensures that all the requested objects, their contained instances, their associated master objects, and all related information is placed in the cache.When
cacheObjectOnClientis called, it first checks to see if the requested object is cached. If it is, then the relevant record is positioned to and nothing further happens. If the record does not exist in the cache, then the function must retrieve the data from the Repository and place it into the cache. If the Repository database is connected, thencacheObjectOnClientrunsbufferFetchObject. This performs the actual retrieval and puts the objects into a cache usingputObjectInCache.If the Repository database is not connected locally, then the function runs
doServerRetrieval. This procedure runsserverFetchObjecton the AppServer.serverFetchObjectrunsbufferFetchObjectand puts the information into temp-tables, which are then returned to the caller.doServerRetrievalthen callsputObjectInCache, which ensures that the objects are in the cache. The last thing thatcacheObjectOnClientdoes is to do aFINDon the requested record in the cache so that it isAVAILABLEto the caller.The
cacheObjectOnClientfunction takes the followingINPUTparameters:
pcLogicalObjectName— ThisCHARACTERparameter is the name of the object to cache. If this is a container, then all of its contained objects are cached as well so that the entire container is ready to be created on the client.pcResultCode— If the client is using a customization, then thisCHARACTERparameter is the result code for that customization. If this parameter is unknown or blank, then the function retrieves theSessionResultCodessession property to establish any default result codes.pcRunAttribute— If the object requires a Progress DynamicsRunattribute as an input value, thisCHARACTERparameter holds that value. If this argument is the unknown value, the function retrieves theRunAttributesession property to see if that defines a default run attribute.plDesignMode— ThisLOGICALparameter isTRUEif the caller is running in design mode rather than run time. In design mode, the client cache is always cleared on each call so that the developer is assured of having the latest changes made to the Repository data by the development tools.The methods
bufferFetchObject,serverFetchObject,doServerRetrieval, andputObjectInCacheshould be considered private to the Repository Manager. You should not normally run these directly.Functions used to retrieve cache table buffer handles
All operations that must use the cache information use the one set of temp-tables where all cached data resides. There is a set of functions to return the buffer handles of the tables in the cache. These are:
With the except of
getCacheObjectBufferandgetCacheClassBuffer, these functions take noINPUTparameters. Each returns theHANDLEof the requested buffer.
getCacheObjectBuffer()takes as an input parameter an optional object instance ID and returns the buffer handle of thecache_Objecttable. If the input value is a non-null instance ID, the function finds the relevant record in thecache_Objecttable before returning the buffer handle. This is important because it means that, with an instance ID, you can get back anAVAILABLEbuffer handle to the record in the cache. This saves having to doFIND-FIRST()to position to the desired record yourself.
getCacheClassBuffer()takes as an input parameter the name of a class (the object type code) and returns the buffer handle of thettClasstemp-table. With this you can read class attributes without starting from a particular object. If you pass in a single, valid class name, the buffer that it returns points to thettClassrecord that corresponds to that class. If the class name passed in to the function does not yet exist in thettClasstable portion of the client cache, the function retrieves it from the Repository. You can also pass in either an asterisk ('*') to represent all classes or a comma-separated list of class names, and all the valid classes in the list are retrieved. However, in this case nottClassrecord is positioned to at the end of the function, since there is no single right record to find.Using the API to retrieve class attributes and values
To be able to access the attributes for a class, you must first get the handle of the attribute buffer. The
ttClassbuffer handle thatgetCacheClassBufferreturns is the handle of the record for the class in thettClasstable, not the handle of the attribute table for the class. The buffer handle of the attribute temp-table is stored in theclassBufferHandlefield of thettClassrecord.This code sample shows how you can retrieve all of the attributes and their default values for a given class, for example, the dynamic SDO or
DynSDO. The first call is to the functiongetCacheClassBufferin the global handle of the Repository Manager. This ensures that theDynSDOclass is in the client cache, and returns the handle of thettClassbuffer. If the data is not already there, it is retrieved from the server. The function does aFINDof the correct record in the cache when it is done, as shown:
The
classBufferHandlefield holds the handle of the buffer handle for the specific dynamic class table for the class’s attributes, in this casecache_DynSDO, as shown:
The variable
hClassAttributeBuffernow points to thecache_DynSDObuffer. Now you can get all the attribute values for the class. TheINITIALvalue of the field represents the default value of each attribute for this class, as shown:
One important thing to keep in mind is that with only one set of buffers to access everything in the cache, you must be aware that records can go out of scope. So, if you find a
cache_Objectrecord and then run an object based on it, chances are that by the time the run statement returns to your procedure, thecache_Objectrecord you were positioned to is no longer current. This is mainly because theprepareInstancefunction (described later) is run for every SmartObject, and it interacts with thecache_Objectrecords. It is very easy to reposition thecache_Objectrecord back to the desired record. If you passgetCacheObjectBuffer() a validRecord Identifier(instance ID), it repositions thecache_Objectbuffer to the correct record. Alternatively, you can use your own set of defined buffers to give you additional buffers whose records won’t be changed out from under you.Accessing Repository data without the cache
If you would rather not use the cache, as would be the case in application design tools, then when making calls from a development tool, you can call
serverFetchObjectdirectly. This procedure returns the requested information in table form. This means that you are guaranteed to get the data as it is in the Repository at any given moment. However, what you lose is the caching. A full description ofserverFetchObjectand other calls that access the data more directly is beyond the scope of this chapter. You should study the code inry/app/ryrepmngrp.iif you are building a development tool that you feel must use these internal calls. Be aware thatserverFetchObject, for example, has a complex calling sequence that includes a large number ofTABLE-HANDLES, each one for a separate temp-table for attribute data related to a particular class of object.Do not use the cache if you want to use the information for design purposes in a tool. Running
cacheObjectOnClient()returns the object in unaggregated form: each result code is separated. If you want to design with aggregated data, then you would need to run this procedure or clear the cache with every call.You can also use the
serverFetchObjectprocedure when you want to retrieve Repository data for external use, for example, in a tool that does some form of analysis or reporting of the Repository data.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |